﻿<Window x:Name="AppMainWindow"
        x:Class="WpfDemoApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mark="MvvmBindingPack"
        xmlns:vm="clr-namespace:WpfDemoApplication.ViewModel"
        xmlns:xaml="clr-namespace:System.Windows.Input;assembly=System"
        Title="MVVM-WPF Markup Dependency Injection Binding Extensions" Height="350" Width="525"
        Loaded="{mark:BindEventHandlerIoc vm:MainWindowVm,ServiceKey=MainWinVM,MethodName=View_Loaded}"
        Unloaded="{mark:BindEventHandlerIoc ServiceType=vm:MainWindowVm,ServiceKey=MainWinVM,MethodName=View_UnLoaded}"
        Closed="{mark:BindEventHandlerIoc ServiceType={x:Type vm:MainWindowVm},ServiceKey=MainWinVM,MethodName=View_Closed}"
        DataContext="{mark:IocBinding ServiceType=vm:MainWindowVm}"
        >
    <Window.Resources>
    </Window.Resources>

    <Grid>
        <Button Content="Button Click Method" HorizontalAlignment="Left" Margin="27,19,0,0" VerticalAlignment="Top" Width="120"
         Click="{mark:BindEventHandlerIoc ServiceKey=MainWinVM,ServiceType=vm:MainWindowVm,MethodName=ButtonClickMethod}"/>
        <!--  Can also be used like these -->
        <!--
        <Button Content="Button Click Method" HorizontalAlignment="Left" Margin="27,19,0,0" VerticalAlignment="Top" Width="120"
         Click="{mark:BindEventHandlerIoc ServiceKey=MainWinVM,ServiceType={x:Type vm:MainWindowVm},MethodName=ButtonClickMethod}"/>
        <Button Content="Button Click Method" HorizontalAlignment="Left" Margin="27,19,0,0" VerticalAlignment="Top" Width="120"
         Click="{mark:BindEventHandlerIoc ServiceType={x:Type vm:MainWindowVm},MethodName=ButtonClickMethod}"/>
        <Button Content="Button Click Method" HorizontalAlignment="Left" Margin="27,19,0,0" VerticalAlignment="Top" Width="120"
         Click="{mark:BindEventHandlerIoc {x:Type vm:MainWindowVm},MethodName=ButtonClickMethod}"/>
        <Button Content="Button Click Method" HorizontalAlignment="Left" Margin="27,19,0,0" VerticalAlignment="Top" Width="120"
         Click="{mark:BindEventHandlerIoc {x:Type vm:MainWindowVm},ServiceKey=MainWinVM,MethodName=ButtonClickMethod}"/>
        -->

        <!-- Sometimes, Don't we need ICommand? to use -->
        <Button Content="Button Click PropDel" HorizontalAlignment="Left" Margin="27,43,0,0" VerticalAlignment="Top" Width="120"
                Click="{mark:BindEventHandlerIoc vm:MainWindowVm,PropertyName=ButtonClickPropDelegate}" 
                IsEnabled="{Binding CanExecuteFlag}" >
        </Button>

        <!--  Can also be used like these -->
        <!--
        <Button Content="Button Click PropDel" HorizontalAlignment="Left" Margin="27,43,0,0" VerticalAlignment="Top" Width="120"
                Click="{mark2:BindEventHandler PropertyName=ButtonClickPropDelegate}" 
                IsEnabled="{Binding CanExecuteFlag}" />
        
        <Button Content="Button Click PropDel" HorizontalAlignment="Left" Margin="27,43,0,0" VerticalAlignment="Top" Width="120"
                Click="{mark:BindEventHandlerIoc ServiceKey=MainWinVM,ServiceType={x:Type vm:MainWindowVm},PropertyName=ButtonClickPropDelegate}"/>
        <Button Content="Button Click PropDel" HorizontalAlignment="Left" Margin="27,43,0,0" VerticalAlignment="Top" Width="120"
                Click="{mark:BindEventHandlerIoc ServiceType={x:Type vm:MainWindowVm},PropertyName=ButtonClickPropDelegate}"/>
        <Button Content="Button Click PropDel" HorizontalAlignment="Left" Margin="27,43,0,0" VerticalAlignment="Top" Width="120"
                Click="{mark:BindEventHandlerIoc {x:Type vm:MainWindowVm},ServiceKey=MainWinVM,PropertyName=ButtonClickPropDelegate}"/>
        <Button Content="Button Click PropDel" HorizontalAlignment="Left" Margin="27,43,0,0" VerticalAlignment="Top" Width="120"
                Click="{mark:BindEventHandlerIoc vm:MainWindowVm,PropertyName=ButtonClickPropDelegate}" 
                IsEnabled="{Binding CanExecuteFlag,Source={mark:IocBinding {x:Type vm:MainWindowVm}}}" />   -->

        <Label Content="{Binding ButtonClickMethodMsg}"
               HorizontalAlignment="Left" Margin="158,19,0,0" VerticalAlignment="Top" Width="323" Background="#FFCDC9C9">
            <mark:BindXAML.AssignProperties>
                <mark:IocBinding ServiceType="MainWindowVm" TargetPropertyName="DataContext"/>
            </mark:BindXAML.AssignProperties>
        </Label>


        <Label Content="{Binding ButtonClickPropMsg,Source={mark:IocBinding ServiceType={x:Type vm:MainWindowVm}}}"
               HorizontalAlignment="Left" Margin="158,43,0,0" VerticalAlignment="Top" Width="323" Background="#FFCDC9C9"/>

        <!--<Button Content="Button Cmd-Ex " HorizontalAlignment="Left" Margin="27,107,0,0" VerticalAlignment="Top" Width="120"
                Command="{mark:BindCommandIoc ServiceType={x:Type vm:MainWindowVm},ServiceKey=MainWinVM,ExecuteMethodName=ExecuteMethod}"/>-->
        <!--  Can also be used like these -->
        <!--
        <Button Content="Button Cmd-Ex " HorizontalAlignment="Left" Margin="27,107,0,0" VerticalAlignment="Top" Width="120"
                Command="{mark:BindCommandIoc ServiceType=vm:MainWindowVm,ServiceKey=MainWinVM,ExecuteMethodName=ExecuteMethod}"/>
        <Button Content="Button Cmd-Ex " HorizontalAlignment="Left" Margin="27,107,0,0" VerticalAlignment="Top" Width="120"
                Command="{mark:BindCommandIoc ServiceType={x:Type vm:MainWindowVm},ExecuteMethodName=ExecuteMethod}"/>
        <Button Content="Button Cmd-Ex " HorizontalAlignment="Left" Margin="27,107,0,0" VerticalAlignment="Top" Width="120"
                Command="{mark:BindCommandIoc {x:Type vm:MainWindowVm},ExecuteMethodName=ExecuteMethod}"/>
         -->


        <Button Content="Button Cmd-Event" HorizontalAlignment="Left" Margin="27,185,0,0" VerticalAlignment="Top" Width="120"
                Command="{mark:BindCommandIoc ServiceType={x:Type vm:MainWindowVm},ServiceKey=MainWinVM,ExecuteMethodName=ExecuteMethod,
                CanExecuteMethodName=CanExecuteMethod,EventToInvokeCanExecuteChanged=EventHandlerNotifyCanExecuteChanged}">
            <mark:BindXAML.BindToCommand>
                <mark:BindCommandIoc ServiceType="MainWindowVm" ServiceKey="MainWinVM" ExecuteMethodName="ExecuteMethod"
                CanExecuteMethodName="CanExecuteMethod" EventToInvokeCanExecuteChanged="EventHandlerNotifyCanExecuteChanged" />
            </mark:BindXAML.BindToCommand>

        </Button>
        
        <!--  Can also be used like these -->
        <!-- 
        <Button Content="Button Cmd-Event" HorizontalAlignment="Left" Margin="27,185,0,0" VerticalAlignment="Top" Width="120"
                Command="{mark:BindCommandIoc ServiceType={x:Type vm:MainWindowVm},ExecuteMethodName=ExecuteMethod,
                CanExecuteMethodName=CanExecuteMethod,EventToInvokeCanExecuteChanged=EventHandlerNotifyCanExecuteChanged}"/>
        -->
        
        <!--  Can also be used like these -->
        <!-- 
                <Button Content="Button Cmd-Del" HorizontalAlignment="Left" Margin="27,209,0,0" VerticalAlignment="Top" Width="120"
                Command="{mark:BindCommandIoc {x:Type vm:MainWindowVm},ExecuteMethodName=ExecuteMethod,
                CanExecuteMethodName=CanExecuteMethod,PropertyActionCanExecuteChanged=PropertyDelegateNotifyCanExecuteChanged}"/>
        -->

        <Button Content="Button Cmd-Prop" HorizontalAlignment="Left" Margin="27,233,0,0" VerticalAlignment="Top" Width="120"
                Command="{mark:BindCommandIoc ServiceType={x:Type vm:MainWindowVm},ServiceKey=MainWinVM,ExecuteMethodName=ExecuteMethod,
               CanExecuteBooleanPropertyName=CanExecuteFlag}"/>
        <!--  Can also be used like these -->
        <!-- 
        <Button Content="Button Cmd-Prop" HorizontalAlignment="Left" Margin="27,233,0,0" VerticalAlignment="Top" Width="120"
                Command="{mark:BindCommandIoc ServiceType={x:Type vm:MainWindowVm},ServiceKey=MainWinVM,ExecuteMethodName=ExecuteMethod,
               CanExecuteBooleanPropertyName=CanExecuteFlag}"/>
        -->
        
        <Button Content="Button Cmd-DI" HorizontalAlignment="Left" Margin="27,257,0,0" VerticalAlignment="Top" Width="120"
               Command="{mark:IocBinding ServiceType={x:Type xaml:ICommand},ServiceKey=JustToDo}" />
      
        <Label Content="{Binding ButtonCommandMsgVariantOne, Source={mark:IocBinding ServiceType={x:Type vm:MainWindowVm}}}"
               HorizontalAlignment="Left" Margin="158,107,0,0" VerticalAlignment="Top" Width="323" Background="#FFCDC9C9"/>

        <CheckBox Content="CanExecute Flag" HorizontalAlignment="Left" Margin="158,189,0,0" VerticalAlignment="Top" Width="134" 
                  IsChecked="{Binding CanExecuteFlag,Mode=TwoWay, Source={mark:IocBinding ServiceType={x:Type vm:MainWindowVm}}}"/>

        <TextBox HorizontalAlignment="Left" Height="23" Margin="158,219,0,0" TextWrapping="Wrap" 
                 Text="{Binding DependencyString,Source={mark:IocBinding ServiceType=vm:MainWindowVm,ServiceKey=MainWinVM}}" 
                 VerticalAlignment="Top" Width="323"/>

        <TextBox HorizontalAlignment="Left" Height="23" Margin="158,254,0,0" TextWrapping="Wrap" 
                 Text="{Binding DependencyString,Source={mark:IocBinding ServiceType={x:Type vm:MainWindowVm}}}" 
                 VerticalAlignment="Top" Width="323"/>

    </Grid>
</Window>
